import { Live } from "./Live";

/** 修饰器 检测优先级是否符合要求, 输入的数字范围的边界也是允许的 */
export const checkPriority =
    (lower: Priority, higher: Priority) => (a: Live, b: string) => {
        const old = a[b];
        return function (...args: any[]) {
            if (a.data.priority >= lower && a.data.priority <= higher) {
                return old.apply(a, args);
            } else {
                return false;
            }
        };
    };

/** 生物的优先级，用于触发行为时的检测 */
export enum Priority {
    dead = 0,
    weak = 1,
    tired = 2,
    normal = 3,
    angry = 4,
    strong = 5,
    invincible = 6,
}
export class BaseData {
    constructor(data: Partial<BaseData>) {
        Object.assign(this, data);
    }
    HP: number = 100;
    priority: Priority = Priority.normal;
}
